﻿#region Using Directives

using System;
using System.IO;

#endregion Using Directives


namespace Kongo.Tags
{
    internal class TemplateTagTag : Tag
    {
        #region Fields

        private string str;

        #endregion Fields


        #region Methods

        public override void Render(Context context, TextWriter output)
        {
            output.Write(str);
        }

        #endregion Methods


        #region Constructors

        public TemplateTagTag(string[] args)
        {
            if (args.Length != 2)
                throw new ArgumentException(); // TODO Be specific

            switch (args[1])
            {
                case "openblock": 
                    str = "{%";
                    break;
                case "closeblock":
                    str = "%}";
                    break;
                case "openvariable":
                    str = "{{";
                    break;
                case "closevariable":
                    str = "}}";
                    break;
                case "openbrace":
                    str = "{";
                    break;
                case "closebrace":
                    str = "}";
                    break;
                case "opencomment":
                    str = "{#";
                    break;
                case "closecomment":
                    str = "#}";
                    break;
                default:
                    throw new ArgumentException(); // TODO Be specific
            }
        }

        #endregion Constructors


        #region Types

        public class TemplateTagTagCreator : ITagCreator
        {
            #region Methods

            public Tag Create(string[] args)
            {
                return new TemplateTagTag(args);
            }

            #endregion Methods
        }

        #endregion Types
    }
}
